<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class settings_model extends CI_Model {
	var $table = "jonu_setting";

	public function get_all(){
		$query = $this->db->get($this->table);
		$result = $query->result_array();
		return $result;
	}

	public function get_by_id($id){
		$this->db->where('jonu_setting_id', "$id");
		$query = $this->db->get($this->table);
		$result = $query->result_array();
		return $result;
	}

	public function update($param){
		# admin pagination (q1)
		$adm_pagination = array('jonu_setting_value' => $param['adm_pagination']);
		$this->db->where('jonu_setting_id', 'adm_pagination');
		$q1 = $this->db->update($this->table, $adm_pagination);

		# home pagination (q2)
		$home_pagination = array('jonu_setting_value' => $param['home_pagination']);
		$this->db->where('jonu_setting_id', 'home_pagination');
		$q2 = $this->db->update($this->table, $home_pagination);

		#post status (q3)
		$post_status = array('jonu_setting_value' => $param['post_status']);
		$this->db->where('jonu_setting_id', 'post_status');
		$q3 = $this->db->update($this->table, $post_status);

		#user pagination (q4)
		$usr_pagination = array('jonu_setting_value' => $param['usr_pagination']);
		$this->db->where('jonu_setting_id', 'user_pagination');
		$q4 = $this->db->update($this->table, $usr_pagination);

		#recommended post (q5)
		$recom_post = array('jonu_setting_value' => $param['recom_post']);
		$this->db->where('jonu_setting_id', 'recom_post');
		$q5 = $this->db->update($this->table, $recom_post);

		#trending (q6)
		$trending = array('jonu_setting_value' => $param['trending']);
		$this->db->where('jonu_setting_id', 'trending');
		$q6 = $this->db->update($this->table, $trending);

		$query = $q1 && $q2 && $q3 && $q4 && $q6;
		return $query;
	}
}

/* End of file settings_model.php */
/* Location: ./application/models/settings_model.php */